function dateFormat(longTypeDate) {
    let dateTypeDate = "";
    let date = new Date(longTypeDate);
    dateTypeDate += date.getFullYear();   //年
    dateTypeDate += "-" + getMonth(date); //月
    dateTypeDate += "-" + getDay(date);   //日
    return dateTypeDate;
}


//返回 01-12 的月份值
function getMonth(date) {
    let month = "";
    month = date.getMonth() + 1; //getMonth()得到的月份是0-11
    if (month < 10) {
        month = "0" + month;
    }
    return month;
}

//返回01-30的日期
function getDay(date) {
    let day = "";
    day = date.getDate();
    if (day < 10) {
        day = "0" + day;
    }
    return day;
}
String.prototype.GetValue = function (para) {
    let query=this.substr(this.indexOf("\?") + 1);
    let vars = query.split("&");
    for (let i=0;i<vars.length;i++) {
        let pair = vars[i].split("=");
        if(pair[0] == para){return unescape(pair[1]);}
    }
    return null;
}
String.prototype.SetValue = function (para, para_value) {
    let destiny = this;
    let pattern = para + '=([^&]*)';
    let replaceText = para + '=' + para_value;
    if (destiny.match(pattern)) {
        let tmp = '/' + para + '=[^&]*/g';
        tmp = destiny.replace(eval(tmp), replaceText);
        return (tmp);
    } else {
        if (destiny.match('[\?]')) {
            return destiny + '&' + replaceText;
        } else {
            return destiny + '?' + replaceText;
        }
    }
    return destiny + '\n' + para + '\n' + para_value;
}

String.prototype.notEmpty = function () {
    return this.trim() != '';
}
String.prototype.isPositiveInteger = function () {
    if (!this.notEmpty())
        return false;
    let regex = /^[0-9]*[1-9][0-9]*$/;
    return regex.test(this.trim());
}
String.prototype.isNumber = function () {
    if (!this.notEmpty())
        return false;
    let regex = /^[0-9]+.?[0-9]*$/;
    return regex.test(this.trim());
}

String.prototype.isIdNumber = function () {
    if (!this.notEmpty())
        return false;
    let regex = /^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
    return regex.test(this.trim());
}
String.prototype.isPhone = function () {
    if (!this.notEmpty())
        return false;
    let regex = /^[1](([3][0-9])|([4][0,1,4-9])|([5][0-3,5-9])|([6][2,5,6,7])|([7][0-8])|([8][0-9])|([9][0-3,5-9]))[0-9]{8}$/;
    return regex.test(this.trim());
}
String.prototype.isTelephone = function () {
    if (!this.notEmpty())
        return false;
    let regex = /^\d{3}-\d{7,8}|\d{4}-\d{7,8}$/;
    return regex.test(this.trim());
}
String.prototype.isEmail = function () {
    if (!this.notEmpty())
        return false;
    let regex = /^[A-Za-zd0-9]+([-_.][A-Za-zd]+)*@([A-Za-zd]+[-.])+[A-Za-zd]{2,5}$/;
    return regex.test(this.trim());
}

String.prototype.isName = function () {
    if (!this.notEmpty())
        return false;
    return this.trim().length >= 2;
}
String.prototype.isValidBirthday = function () {
    if (!this.notEmpty())
        return false;
    return this.trim().split("-")[0] >= 1900 && Date.now() > new Date(this);
}
String.prototype.isHKPass = function () {
    if (!this.notEmpty())
        return false;
    let regex = /^([A-Z]\d{6,10}(\(\w{1}\))?)$/;
    return regex.test(this.trim());
}
String.prototype.isPositiveNumber = function () {
    if (!this.notEmpty())
        return false;
    let regex = /^[+]{0,1}[1-9]\d*$|^[+]{0,1}(0\.\d*[1-9])$|^[+]{0,1}([1-9]\d*\.\d*[1-9])$/
    return regex.test(this.trim());
}
String.prototype.isPassport = function () {
    if (!this.notEmpty())
        return false;
    let regex = /^([a-zA-z]|[0-9]){5,17}$/;
    return regex.test(this.trim());
}

String.prototype.isPassport = function () {
    if (!this.notEmpty())
        return false;
    let regex = /^([a-zA-z]|[0-9]){5,17}$/;
    return regex.test(this.trim());
}